package com.shop.vuedemo.filter;

import com.shop.vuedemo.config.ApplicationContextHelper;
import com.shop.vuedemo.service.shop.TzSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

/**
 * projectName: vueDemo
 * create on 2021/11/21 20:39
 *
 * @author yanbl
 * @Description : 测试
 */
@Component
public class MyFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Autowired
    private TzSkuService tzSkuService;

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println("testFilter 执行了");
        System.out.println(servletRequest.getServerName());
        System.out.println(servletRequest.getServletContext());
        tzSkuService.testFilter();
        ApplicationContextHelper.getBean(TzSkuService.class).testFilter();
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

    }
}
